Skip to content

fix: patch fypp to emit resync linemarker after single-line $: calls#1436

Merged
sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:fix/fypp-linemarker-drift
May 13, 2026
Merged

fix: patch fypp to emit resync linemarker after single-line $: calls#1436
sbryngelson merged 3 commits into
MFlowCode:masterfrom
sbryngelson:fix/fypp-linemarker-drift

Conversation

@sbryngelson
Copy link
Copy Markdown
Member

@sbryngelson sbryngelson commented May 13, 2026

Referencing #1435

Problem

fypp's _postprocess_eval_line only emitted a trailing resync linemarker
when the output was multi-line or continuation lines were out of sync. For
single-line $: / @: / inline #{...}# calls this condition was never
true, so no resync was written.

When a macro expanded by such a call contains #ifdef/#endif blocks,
downstream Fortran preprocessors (gfortran -cpp, flang) skip the content
of never-taken branches but still advance their internal line counter over
those physical lines. Without a resync marker after the expansion, every
subsequent source line is attributed to the wrong location — producing
misleading compile-time diagnostics and incorrect debugger line info.

Changes

toolchain/patches/fypp-linemarker-resync.patch + toolchain/bootstrap/python.sh

Applies a patch to fypp at build time that unconditionally emits the resync
marker after every eval directive. An upstream fix has been submitted:
aradi/fypp#66. Once that is released,
this patch and its application in python.sh can be removed (tracked in #1435).

.fpp source changes

Several source files had long Fortran continuation lines that crossed fypp
macro-expansion boundaries in a way that triggered the bug. These are reformatted
so that each continuation segment is self-contained, fixing the immediate
symptom regardless of fypp version.

Draft status

Marked as draft pending review of the source reformats and CI results. Will be
ready to merge once CI passes; the patch can be dropped in a follow-up once
aradi/fypp#66 is tagged in a release.

Single-line $:GPU_PARALLEL_LOOP() and similar macros expand to
leaving the next Fortran statement attributed to the macro call-site
line rather than the following source line. This causes off-by-1
errors in all backtraces, compiler error messages, and debugger line
info for every GPU-macro-wrapped loop body in the codebase (~2188
affected call sites).

Root cause: fypp's _postprocess_eval_line only emits a trailing
resync linemarker when the $: call spans >1 source lines (multiline)
or when line-folding splits output (unsync). Single-line calls that
produce multi-line output hit neither condition.

Fix: always emit the resync marker after any $: call that ends its
line. Implemented as a patch applied to the installed fypp.py after
venv setup in toolchain/bootstrap/python.sh, with a sentinel check
so it is idempotent across reinstalls.
@sbryngelson sbryngelson force-pushed the fix/fypp-linemarker-drift branch from f57c3ef to b1edca0 Compare May 13, 2026 15:37
@sbryngelson sbryngelson marked this pull request as ready for review May 13, 2026 17:37
@qodo-code-review
Copy link
Copy Markdown
Contributor

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@github-actions
Copy link
Copy Markdown

Claude Code Review

Head SHA: b1edca0

Files changed:

  • 3
  • src/common/include/2dHardcodedIC.fpp
  • toolchain/bootstrap/python.sh
  • toolchain/patches/fypp-linemarker-resync.patch

Findings

toolchain/bootstrap/python.sh — Fragile idempotency sentinel for the fypp patch

The already-applied check uses:

if ! grep -q "or True" "$FYPP_PY" 2>/dev/null; then

or True is an extremely common Python idiom. If any future version of fypp contains that string elsewhere in the file (as actual logic, in a string literal, or even in a comment), this guard would trigger prematurely and patch application would be silently skipped. The result would be that every $:GPU_PARALLEL_LOOP expansion produces off-by-1 line numbers in compiler diagnostics and debugger info — the exact problem the patch is meant to fix.

The patch itself adds a distinctive comment that is virtually guaranteed to be unique:

# Always emit a resync marker after a $: call. Without this,

Using that string as the sentinel is far more robust:

if ! grep -q "Always emit a resync marker" "$FYPP_PY" 2>/dev/null; then

@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.00%. Comparing base (060f752) to head (3044f14).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1436   +/-   ##
=======================================
  Coverage   65.00%   65.00%           
=======================================
  Files          72       72           
  Lines       18810    18810           
  Branches     1553     1553           
=======================================
  Hits        12227    12227           
  Misses       5615     5615           
  Partials      968      968           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sbryngelson sbryngelson merged commit b40c0bf into MFlowCode:master May 13, 2026
79 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant